package com.yin.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.yin.entity.UsersEntity;
import com.yin.jpa.UserJPA;

/**
*@author LSY
*Time: 2018年12月27日下午1:53:18
*
*
*/
public class UserService implements UserDetailsService{

	@Autowired
	private UserJPA userJPA;
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		UsersEntity user = userJPA.findByUsername(username);
		if(user == null) {
			throw new UsernameNotFoundException("未查到用户：" + username + "信息！");
		}
		return user;
	}

}
